package com.framework.SystemPage
{
	import com.framework.BasicButton;
	import com.framework.BasicPage;
	import com.framework.ButtonInfo;
	import com.framework.GameUI.StageButton;
	
	import flash.display.MovieClip;
	import flash.events.Event;
	
	import flashx.textLayout.events.ModelChange;

	public class StageSelectPage extends BasicPage
	{
		public var stage_id:int;
		private var row:int;
		private var column:int;
		public var arrSelectButtons:Array;
		private const distance:int = 60;
				
		public function StageSelectPage()
		{
			super();
		}
		
		override public function init(e:Event):void
		{
			super.init(e);
		//	createSelections(3,10);
		}
		
		override public function update(e:Event):void
		{
			
		}
		
		public function createSelections(stageId:int ,row:int,total:int):void
		{
			var currLevelId:int = 0;
			var tmp_row:int = 0;
			var tmp_x:int = 0;
			
			while(currLevelId<total)
			{
				
				for(var i:int = 0;i<row && currLevelId<total;i++)
				{
					//var btnNew:MovieClip= createButton(stageId);
					var btnNew:StageButton = new StageButton(stageId,currLevelId+1);
					btnNew.setButton(stageId);
					btnNew.alpha = 90;
					btnNew.addButtonEventListener();
					btnNew.y = i*distance;
					btnNew.x = tmp_x;
					trace(btnNew.x);
					addChild(btnNew);
					currLevelId++;
					
				}
				tmp_x += distance;
			}
			
		}
		
		/*
		public function createButton(stage_id:int):MovieClip
		{
			switch(stage_id)
			{
				case 1:
					return new resStageBtn1();
					break;
				case 2:
					return new resStageBtn2();
					break;
				case 3:
					return new resStageBtn3();
					break;
			}
			return null;
		}
		*/
		
		public function createBoard(stage_id:int,x:int,y:int):MovieClip
		{
			var temp:MovieClip = null;
			switch(stage_id)
			{
				case 1:
					temp =  new resStageBoard1();
					break;
				case 2:
					temp =  new resStageBoard2();
					break;
				case 3:
					temp =  new resStageBoard3();
					break;
			}
			temp.x = x;
			temp.y = y;
			if(temp!=null)
			{
				this.addChild(temp);
			}
			return temp;
		}
	}
}